package com.xohm.platform.api;

/**
 * Xohm Connection Manager
 *
 * Licensed Material - Property of Sprint Nextel
 * Restricted Materials of Sprint Nextel
 * (C) Copyright Sprint Nextel Corp. 2008 - All Rights Reserved.
 *
 * This class determines the OS and creates the apporpriate OSAPI class and
 * returns it to the receiver.
 *
 * @author Robin Katzer
 */
public class OSAPIFactory extends OSAPIBase
{
	private static OSAPIFactory singleton = null;
	private OSAPIInterface os = null;
	
	private OSAPIFactory()
	{
	}
	
	private static OSAPIFactory getSingleton()
	{
		if (singleton == null)
		{
			singleton = new OSAPIFactory();
		}
		
		return singleton;
	}

	/**
	 * Get the appopriate OS connection manager for the operating system that
	 * your on and return it to the receiver.
	 * 
	 * @return com.xohm.cm.os.ConnectionManagerInterface
	 */
	public static OSAPIInterface getConnectionManager()
	{
		return OSAPIFactory.getSingleton().getOSAPI();
	}

	/**
	 * Get the appopriate connection for the operating system that your on and
	 * return it to the receiver.
	 * 
	 * @return com.xohm.cm.os.ConnectionManagerInterface
	 */
	private OSAPIInterface getOSAPI()
	{
		if (os == null)
		{
			if (isWindows())
			{
				os = new OSAPIWindows();
			} else {
			if (isMac())
			{
				os = new OSAPIMac();
			} else {
			if (isLinux())
			{
				os = new OSAPILinux();
			}}}
		}
		
		return os;
	}
}
